<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>块级元素定宽高垂直居中3</title>
    <style>
        .box {
            border: 1px solid black;
            width: 300px;
            height: 300px;
            /*  */
            position: absolute;
            top: calc(50% - 150px);
            left: calc(50% - 150px);
        }
    </style>
</head>

<body>
    <div class="box">定宽高水平垂直居中
        <br>position: absolute;
        <br>top: calc(50% - 150px);
        <br>left: calc(50% - 150px);
        <br>使用CSS3新属性calc
    </div>

</body>

</html>